package com.fzb.ftp;

import java.io.File;


public class FtpManager {

	public void putFile(FtpUser ftpUser,final File file){
		FtpLoginSuccCallBack callBack=new FtpLoginSuccCallBack() {
			@Override
			public void callBack(FtpSession ftpSession) {
				new FtpReqeustImpl(ftpSession).sendCmd("put "+file.toString());
				while(FtpReqeustImpl.getlock()){
				}
				ftpSession.close();
			}
		};
		FtpNIOClient ftpNIOClient=new FtpNIOClient(callBack,ftpUser);
		ftpNIOClient.connectServer();
	}
	
	public void sendCmd(FtpUser ftpUser,final String... cmds){
		FtpLoginSuccCallBack callBack=new FtpLoginSuccCallBack() {
			@Override
			public void callBack(FtpSession ftpSession) {
				for(String cmd:cmds){
					System.out.println("send cmd --> "+cmd);
					new FtpReqeustImpl(ftpSession).sendCmd(cmd);
				}
				while(FtpReqeustImpl.getlock()){
					
				}
				System.exit(-1);
			}
		};
		FtpNIOClient ftpNIOClient=new FtpNIOClient(callBack,ftpUser);
		ftpNIOClient.connectServer();
	}
}
